﻿Imports System.Data.OleDb
Imports System.Xml
Imports System.Text
Public Class RssFeed
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Response.Clear()
        Response.ContentType = "application/rss+xml"
        Dim objX As New XmlTextWriter(Response.OutputStream, Encoding.UTF8)
        objX.WriteStartDocument()
        objX.WriteStartElement("rss")
        objX.WriteAttributeString("version", "2.0")
        objX.WriteStartElement("channel")

        Dim cmd As New OleDbCommand("SELECT Player.Name, Player.DOB, Player.Nickname, Player.BattingStyle, Player.BowlingStyle, Player.Role, Player.PlayerPhoto, InternationalCricketTeams.NationFlag, InternationalCricketTeams.Nation, Player.ID, InternationalCricketTeams.TeamLogo FROM (InternationalCricketTeams INNER JOIN Player ON InternationalCricketTeams.ID = Player.Nation)", New OleDbConnection(ConfigurationManager.ConnectionStrings("ConnStringWorldsCricket").ConnectionString))
        cmd.Connection.Open()
        Dim dr As OleDbDataReader = cmd.ExecuteReader()

        objX.WriteElementString("title", "Cricketer Name")
        objX.WriteElementString("link", "http://localhost:56630/List.aspx")
        objX.WriteElementString("description", "Cricket Forum  is the simplest ASP.NET website which gives information on Cricket Game!")
        objX.WriteElementString("language", "en-us")
        objX.WriteElementString("ttl", "60")
        objX.WriteElementString("lastBuildDate", String.Format("{0:R}", DateTime.Now))

        Do While dr.Read()
            objX.WriteStartElement("item")
            objX.WriteElementString("title", dr("Name").ToString())
            objX.WriteElementString("Nation", dr("Nation").ToString())
            objX.WriteElementString("DOB", dr("DOB").ToString())
            objX.WriteElementString("Nickname", dr("Nickname").ToString())
            objX.WriteElementString("Role", dr("Role").ToString())
            objX.WriteStartElement("guid")
            objX.WriteAttributeString("isPermaLink", "true")
            objX.WriteString("http://localhost:56630/Details.aspx?ID=" & dr("ID").ToString())
            objX.WriteEndElement()
            objX.WriteEndElement()
        Loop

        objX.WriteEndElement()
        objX.WriteEndElement()
        objX.WriteEndDocument()
        objX.Flush()
        objX.Close()
        Response.End()
    End Sub

End Class